package com.wtc.interface_;

public class InnerClassExercise02 {
    public static void main(String[] args) {
        CellPhone cellPhone = new CellPhone();
        /*
        老韩解读
        1. 传递的是实现了 Bell接口的匿名内部类 InnerClassExercise02$1
        2. 重写了 ring
        3. Bell bell = new Bell() {
               @Override
               public void ring() {
                   System.out.println("懒猪起床了");
              }
          }
         */
        cellPhone.alarmClock(new Bell() {
            @Override
            public void ring() {
                System.out.println("懒猪起床了！");
            }
        });
        cellPhone.alarmClock(new Bell() {
            @Override
            public void ring() {
                System.out.println("小伙伴上课了！");
            }
        });
    }
}

interface Bell {
    void ring();
}

class CellPhone {
    public void alarmClock(Bell bell) {
        bell.ring();
    }
}
